package com.intelligent.pojo;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 供应商对账单主表
 * @TableName supplier_reconciliation
 */
@TableName(value ="supplier_reconciliation")
@Data
public class SupplierReconciliation implements Serializable {
    /**
     *
     */
    @TableId(type = IdType.AUTO)
    private Long id;

    /**
     * 关联供应商ID
     */
    @TableField("supplier_id")
    private Long supplierId;

    /**
     * 财务人员ID（关联 t_user.user_id）
     */
    @TableField("u_id")
    private Long uId;

    /**
     * 对账周期（如 2023-08）
     */
    @TableField("reconciliation_period")
    private String reconciliationPeriod;

    /**
     * 采购总金额
     */
    @TableField("total_purchase")
    private BigDecimal totalPurchase;

    /**
     * 收货总金额
     */
    @TableField("total_receipt")
    private BigDecimal totalReceipt;

    /**
     * 付款总金额
     */
    @TableField("total_payment")
    private BigDecimal totalPayment;

    /**
     * 状态：0待对账、1已对账
     */
    @TableField("status")
    private Integer status;

    /**
     *
     */
    @TableField("create_time")
    private Date createTime;

    /**
     * 对账单号
     */
    @TableField("reconciliation_no")
    private String reconciliationNo;

    /**
     * 备注
     */
    @TableField("remarks")
    private String remarks;

    /**
     * 供应商名称（非持久化字段）
     */
    @TableField(exist = false)
    private String supplierName;

    /**
     * 财务人员姓名（非持久化字段）
     */
    @TableField(exist = false)
    private String financeStaffName;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        SupplierReconciliation other = (SupplierReconciliation) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getSupplierId() == null ? other.getSupplierId() == null : this.getSupplierId().equals(other.getSupplierId()))
            && (this.getReconciliationPeriod() == null ? other.getReconciliationPeriod() == null : this.getReconciliationPeriod().equals(other.getReconciliationPeriod()))
            && (this.getTotalPurchase() == null ? other.getTotalPurchase() == null : this.getTotalPurchase().equals(other.getTotalPurchase()))
            && (this.getTotalReceipt() == null ? other.getTotalReceipt() == null : this.getTotalReceipt().equals(other.getTotalReceipt()))
            && (this.getTotalPayment() == null ? other.getTotalPayment() == null : this.getTotalPayment().equals(other.getTotalPayment()))
            && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getSupplierId() == null) ? 0 : getSupplierId().hashCode());
        result = prime * result + ((getReconciliationPeriod() == null) ? 0 : getReconciliationPeriod().hashCode());
        result = prime * result + ((getTotalPurchase() == null) ? 0 : getTotalPurchase().hashCode());
        result = prime * result + ((getTotalReceipt() == null) ? 0 : getTotalReceipt().hashCode());
        result = prime * result + ((getTotalPayment() == null) ? 0 : getTotalPayment().hashCode());
        result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        return result;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", id=").append(id);
        sb.append(", supplierId=").append(supplierId);
        sb.append(", reconciliationPeriod=").append(reconciliationPeriod);
        sb.append(", totalPurchase=").append(totalPurchase);
        sb.append(", totalReceipt=").append(totalReceipt);
        sb.append(", totalPayment=").append(totalPayment);
        sb.append(", status=").append(status);
        sb.append(", createTime=").append(createTime);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }
}
